{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Pandas"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "# Pandas Library\n",
        "import pandas as pd"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.703Z",
          "iopub.execute_input": "2022-01-28T01:13:42.710Z",
          "iopub.status.idle": "2022-01-28T01:13:42.718Z",
          "shell.execute_reply": "2022-01-28T01:13:42.399Z"
        }
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Import Finance Data (Historical Prices)"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "# yfinance is used to fetch data \n",
        "import yfinance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 2,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.728Z",
          "iopub.execute_input": "2022-01-28T01:13:42.735Z",
          "iopub.status.idle": "2022-01-28T01:13:42.743Z",
          "shell.execute_reply": "2022-01-28T01:13:42.407Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2014-01-01'\n",
        "end = '2018-08-27'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View Columns\n",
        "# Dataframe\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 completed\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 3,
          "data": {
            "text/plain": "            Open  High   Low  Close  Adj Close    Volume\nDate                                                    \n2014-01-02  3.85  3.98  3.84   3.95       3.95  20548400\n2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200\n2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300\n2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100\n2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n    </tr>\n    <tr>\n      <th>2014-01-03</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 3,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.753Z",
          "iopub.execute_input": "2022-01-28T01:13:42.760Z",
          "iopub.status.idle": "2022-01-28T01:13:42.783Z",
          "shell.execute_reply": "2022-01-28T01:13:42.415Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset.rolling(window=5).mean() # Find the mean for last 4 rows"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 4,
          "data": {
            "text/plain": "                 Open    High     Low   Close  Adj Close      Volume\nDate                                                                \n2014-01-02        NaN     NaN     NaN     NaN        NaN         NaN\n2014-01-03        NaN     NaN     NaN     NaN        NaN         NaN\n2014-01-06        NaN     NaN     NaN     NaN        NaN         NaN\n2014-01-07        NaN     NaN     NaN     NaN        NaN         NaN\n2014-01-08   4.052000   4.134   3.992   4.088      4.088  31888940.0\n...               ...     ...     ...     ...        ...         ...\n2018-08-20  19.720000  20.070  19.232  19.760     19.760  73776940.0\n2018-08-21  19.722001  20.098  19.278  19.836     19.836  67063640.0\n2018-08-22  19.806001  20.262  19.480  20.076     20.076  62193040.0\n2018-08-23  20.072001  20.712  19.858  20.668     20.668  70935120.0\n2018-08-24  20.830000  21.548  20.646  21.510     21.510  91677440.0\n\n[1171 rows x 6 columns]",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2014-01-03</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.052000</td>\n      <td>4.134</td>\n      <td>3.992</td>\n      <td>4.088</td>\n      <td>4.088</td>\n      <td>31888940.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>2018-08-20</th>\n      <td>19.720000</td>\n      <td>20.070</td>\n      <td>19.232</td>\n      <td>19.760</td>\n      <td>19.760</td>\n      <td>73776940.0</td>\n    </tr>\n    <tr>\n      <th>2018-08-21</th>\n      <td>19.722001</td>\n      <td>20.098</td>\n      <td>19.278</td>\n      <td>19.836</td>\n      <td>19.836</td>\n      <td>67063640.0</td>\n    </tr>\n    <tr>\n      <th>2018-08-22</th>\n      <td>19.806001</td>\n      <td>20.262</td>\n      <td>19.480</td>\n      <td>20.076</td>\n      <td>20.076</td>\n      <td>62193040.0</td>\n    </tr>\n    <tr>\n      <th>2018-08-23</th>\n      <td>20.072001</td>\n      <td>20.712</td>\n      <td>19.858</td>\n      <td>20.668</td>\n      <td>20.668</td>\n      <td>70935120.0</td>\n    </tr>\n    <tr>\n      <th>2018-08-24</th>\n      <td>20.830000</td>\n      <td>21.548</td>\n      <td>20.646</td>\n      <td>21.510</td>\n      <td>21.510</td>\n      <td>91677440.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>1171 rows × 6 columns</p>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 4,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.794Z",
          "iopub.execute_input": "2022-01-28T01:13:42.801Z",
          "iopub.status.idle": "2022-01-28T01:13:42.815Z",
          "shell.execute_reply": "2022-01-28T01:13:42.423Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset.rolling(window=5).std() # Find the standarad deviation for last 4 rows"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 5,
          "data": {
            "text/plain": "                Open      High       Low     Close  Adj Close        Volume\nDate                                                                       \n2014-01-02       NaN       NaN       NaN       NaN        NaN           NaN\n2014-01-03       NaN       NaN       NaN       NaN        NaN           NaN\n2014-01-06       NaN       NaN       NaN       NaN        NaN           NaN\n2014-01-07       NaN       NaN       NaN       NaN        NaN           NaN\n2014-01-08  0.156908  0.135204  0.133679  0.106630   0.106630  1.052974e+07\n...              ...       ...       ...       ...        ...           ...\n2018-08-20  0.341540  0.164013  0.326221  0.275953   0.275953  1.324768e+07\n2018-08-21  0.343395  0.213354  0.403448  0.392976   0.392976  1.191929e+07\n2018-08-22  0.426825  0.425230  0.572189  0.600691   0.600691  5.076759e+06\n2018-08-23  0.756221  0.988595  0.908003  1.004525   1.004525  2.393107e+07\n2018-08-24  1.280878  1.614782  1.306533  1.632054   1.632054  4.678504e+07\n\n[1171 rows x 6 columns]",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2014-01-03</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>0.156908</td>\n      <td>0.135204</td>\n      <td>0.133679</td>\n      <td>0.106630</td>\n      <td>0.106630</td>\n      <td>1.052974e+07</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>2018-08-20</th>\n      <td>0.341540</td>\n      <td>0.164013</td>\n      <td>0.326221</td>\n      <td>0.275953</td>\n      <td>0.275953</td>\n      <td>1.324768e+07</td>\n    </tr>\n    <tr>\n      <th>2018-08-21</th>\n      <td>0.343395</td>\n      <td>0.213354</td>\n      <td>0.403448</td>\n      <td>0.392976</td>\n      <td>0.392976</td>\n      <td>1.191929e+07</td>\n    </tr>\n    <tr>\n      <th>2018-08-22</th>\n      <td>0.426825</td>\n      <td>0.425230</td>\n      <td>0.572189</td>\n      <td>0.600691</td>\n      <td>0.600691</td>\n      <td>5.076759e+06</td>\n    </tr>\n    <tr>\n      <th>2018-08-23</th>\n      <td>0.756221</td>\n      <td>0.988595</td>\n      <td>0.908003</td>\n      <td>1.004525</td>\n      <td>1.004525</td>\n      <td>2.393107e+07</td>\n    </tr>\n    <tr>\n      <th>2018-08-24</th>\n      <td>1.280878</td>\n      <td>1.614782</td>\n      <td>1.306533</td>\n      <td>1.632054</td>\n      <td>1.632054</td>\n      <td>4.678504e+07</td>\n    </tr>\n  </tbody>\n</table>\n<p>1171 rows × 6 columns</p>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 5,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.827Z",
          "iopub.execute_input": "2022-01-28T01:13:42.834Z",
          "iopub.status.idle": "2022-01-28T01:13:42.846Z",
          "shell.execute_reply": "2022-01-28T01:13:42.432Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# exponential weighted functions\n",
        "dataset['ewm'] = dataset['Adj Close'].ewm(span=20,min_periods=0,adjust=False,ignore_na=False).mean()\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 6,
          "data": {
            "text/plain": "            Open  High   Low  Close  Adj Close    Volume       ewm\nDate                                                              \n2014-01-02  3.85  3.98  3.84   3.95       3.95  20548400  3.950000\n2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200  3.954762\n2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300  3.971451\n2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100  3.991313\n2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700  4.009283",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>ewm</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n    </tr>\n    <tr>\n      <th>2014-01-03</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 6,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.857Z",
          "iopub.execute_input": "2022-01-28T01:13:42.865Z",
          "iopub.status.idle": "2022-01-28T01:13:42.878Z",
          "shell.execute_reply": "2022-01-28T01:13:42.452Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# iloc[] examples\n",
        "print(dataset.iloc[0][0])"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "3.8499999046325684\n"
          ]
        }
      ],
      "execution_count": 7,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.888Z",
          "iopub.execute_input": "2022-01-28T01:13:42.895Z",
          "iopub.status.idle": "2022-01-28T01:13:42.907Z",
          "shell.execute_reply": "2022-01-28T01:13:42.462Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# iat[] examples\n",
        "print(dataset.iat[0,0])"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "3.8499999046325684\n"
          ]
        }
      ],
      "execution_count": 8,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.917Z",
          "iopub.execute_input": "2022-01-28T01:13:42.923Z",
          "iopub.status.idle": "2022-01-28T01:13:42.937Z",
          "shell.execute_reply": "2022-01-28T01:13:42.469Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "df = dataset.reset_index()\n",
        "df.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 9,
          "data": {
            "text/plain": "        Date  Open  High   Low  Close  Adj Close    Volume       ewm\n0 2014-01-02  3.85  3.98  3.84   3.95       3.95  20548400  3.950000\n1 2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200  3.954762\n2 2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300  3.971451\n3 2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100  3.991313\n4 2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700  4.009283",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Date</th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>ewm</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2014-01-02</td>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2014-01-03</td>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2014-01-06</td>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2014-01-07</td>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2014-01-08</td>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 9,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.948Z",
          "iopub.execute_input": "2022-01-28T01:13:42.955Z",
          "iopub.status.idle": "2022-01-28T01:13:42.967Z",
          "shell.execute_reply": "2022-01-28T01:13:42.476Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# loc[] examples\n",
        "print(df.loc[0]['High'])"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "3.9800000190734863\n"
          ]
        }
      ],
      "execution_count": 10,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:42.977Z",
          "iopub.execute_input": "2022-01-28T01:13:42.985Z",
          "iopub.status.idle": "2022-01-28T01:13:42.997Z",
          "shell.execute_reply": "2022-01-28T01:13:42.485Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# iloc[] examples\n",
        "print(df.iloc[0])"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Date         2014-01-02 00:00:00\n",
            "Open                        3.85\n",
            "High                        3.98\n",
            "Low                         3.84\n",
            "Close                       3.95\n",
            "Adj Close                   3.95\n",
            "Volume                  20548400\n",
            "ewm                         3.95\n",
            "Name: 0, dtype: object\n"
          ]
        }
      ],
      "execution_count": 11,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:43.008Z",
          "iopub.execute_input": "2022-01-28T01:13:43.015Z",
          "iopub.status.idle": "2022-01-28T01:13:43.028Z",
          "shell.execute_reply": "2022-01-28T01:13:42.496Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Specify Column\n",
        "print(df.iloc[0]['Volume'])"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "20548400\n"
          ]
        }
      ],
      "execution_count": 12,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:43.038Z",
          "iopub.execute_input": "2022-01-28T01:13:43.046Z",
          "iopub.status.idle": "2022-01-28T01:13:43.059Z",
          "shell.execute_reply": "2022-01-28T01:13:42.504Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# at[] examples\n",
        "print(df.at[0,'Low'])"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "3.8399999141693115\n"
          ]
        }
      ],
      "execution_count": 13,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:43.071Z",
          "iopub.execute_input": "2022-01-28T01:13:43.079Z",
          "iopub.status.idle": "2022-01-28T01:13:43.091Z",
          "shell.execute_reply": "2022-01-28T01:13:42.513Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Remove column example\n",
        "# Remove Date\n",
        "new_df = df.drop(['Date'], axis=1)\n",
        "new_df.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 14,
          "data": {
            "text/plain": "   Open  High   Low  Close  Adj Close    Volume       ewm\n0  3.85  3.98  3.84   3.95       3.95  20548400  3.950000\n1  3.98  4.00  3.88   4.00       4.00  22887200  3.954762\n2  4.01  4.18  3.99   4.13       4.13  42398300  3.971451\n3  4.19  4.25  4.11   4.18       4.18  42932100  3.991313\n4  4.23  4.26  4.14   4.18       4.18  30678700  4.009283",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>ewm</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 14,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:43.102Z",
          "iopub.execute_input": "2022-01-28T01:13:43.109Z",
          "iopub.status.idle": "2022-01-28T01:13:43.123Z",
          "shell.execute_reply": "2022-01-28T01:13:42.523Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Add column example\n",
        "# Add Date\n",
        "new_column = df['Date']"
      ],
      "outputs": [],
      "execution_count": 15,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:43.136Z",
          "iopub.execute_input": "2022-01-28T01:13:43.143Z",
          "iopub.status.idle": "2022-01-28T01:13:43.152Z",
          "shell.execute_reply": "2022-01-28T01:13:42.533Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "new_df['Date'] = new_column\n",
        "new_df.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 16,
          "data": {
            "text/plain": "   Open  High   Low  Close  Adj Close    Volume       ewm       Date\n0  3.85  3.98  3.84   3.95       3.95  20548400  3.950000 2014-01-02\n1  3.98  4.00  3.88   4.00       4.00  22887200  3.954762 2014-01-03\n2  4.01  4.18  3.99   4.13       4.13  42398300  3.971451 2014-01-06\n3  4.19  4.25  4.11   4.18       4.18  42932100  3.991313 2014-01-07\n4  4.23  4.26  4.14   4.18       4.18  30678700  4.009283 2014-01-08",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>ewm</th>\n      <th>Date</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n      <td>2014-01-02</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n      <td>2014-01-03</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n      <td>2014-01-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n      <td>2014-01-07</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n      <td>2014-01-08</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 16,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.543Z",
          "iopub.status.busy": "2022-01-28T01:13:43.163Z",
          "iopub.execute_input": "2022-01-28T01:13:43.169Z",
          "iopub.status.idle": "2022-01-28T01:13:43.182Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Move column example\n",
        "# Move Date in the first column\n",
        "cols = new_df.columns.to_list()\n",
        "cols.insert(0, cols.pop(cols.index('Date')))\n",
        "cols"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 17,
          "data": {
            "text/plain": "['Date', 'Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume', 'ewm']"
          },
          "metadata": {}
        }
      ],
      "execution_count": 17,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:43.194Z",
          "iopub.execute_input": "2022-01-28T01:13:43.201Z",
          "iopub.status.idle": "2022-01-28T01:13:43.214Z",
          "shell.execute_reply": "2022-01-28T01:13:42.551Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# iloc() function enables us to select a particular cell of the dataset\n",
        "new_df = new_df.iloc[:]\n",
        "new_df.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 18,
          "data": {
            "text/plain": "   Open  High   Low  Close  Adj Close    Volume       ewm       Date\n0  3.85  3.98  3.84   3.95       3.95  20548400  3.950000 2014-01-02\n1  3.98  4.00  3.88   4.00       4.00  22887200  3.954762 2014-01-03\n2  4.01  4.18  3.99   4.13       4.13  42398300  3.971451 2014-01-06\n3  4.19  4.25  4.11   4.18       4.18  42932100  3.991313 2014-01-07\n4  4.23  4.26  4.14   4.18       4.18  30678700  4.009283 2014-01-08",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>ewm</th>\n      <th>Date</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n      <td>2014-01-02</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n      <td>2014-01-03</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n      <td>2014-01-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n      <td>2014-01-07</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n      <td>2014-01-08</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 18,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:43.226Z",
          "iopub.execute_input": "2022-01-28T01:13:43.234Z",
          "shell.execute_reply": "2022-01-28T01:13:42.561Z",
          "iopub.status.idle": "2022-01-28T01:13:43.248Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "new_df.iloc[2]"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 19,
          "data": {
            "text/plain": "Open                        4.01\nHigh                        4.18\nLow                         3.99\nClose                       4.13\nAdj Close                   4.13\nVolume                  42398300\newm                      3.97145\nDate         2014-01-06 00:00:00\nName: 2, dtype: object"
          },
          "metadata": {}
        }
      ],
      "execution_count": 19,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2022-01-28T01:13:43.261Z",
          "iopub.execute_input": "2022-01-28T01:13:43.269Z",
          "iopub.status.idle": "2022-01-28T01:13:43.284Z",
          "shell.execute_reply": "2022-01-28T01:13:42.570Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Delete the column\n",
        "del new_df['Close']"
      ],
      "outputs": [],
      "execution_count": 20,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.579Z",
          "iopub.status.busy": "2022-01-28T01:13:43.297Z",
          "iopub.execute_input": "2022-01-28T01:13:43.304Z",
          "iopub.status.idle": "2022-01-28T01:13:43.313Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "new_df.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 21,
          "data": {
            "text/plain": "   Open  High   Low  Adj Close    Volume       ewm       Date\n0  3.85  3.98  3.84       3.95  20548400  3.950000 2014-01-02\n1  3.98  4.00  3.88       4.00  22887200  3.954762 2014-01-03\n2  4.01  4.18  3.99       4.13  42398300  3.971451 2014-01-06\n3  4.19  4.25  4.11       4.18  42932100  3.991313 2014-01-07\n4  4.23  4.26  4.14       4.18  30678700  4.009283 2014-01-08",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>ewm</th>\n      <th>Date</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n      <td>2014-01-02</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n      <td>2014-01-03</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n      <td>2014-01-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n      <td>2014-01-07</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n      <td>2014-01-08</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 21,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.588Z",
          "iopub.status.busy": "2022-01-28T01:13:43.324Z",
          "iopub.execute_input": "2022-01-28T01:13:43.331Z",
          "iopub.status.idle": "2022-01-28T01:13:43.349Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Rename column\n",
        "new_df = new_df.rename(index=str, columns={'Adj Close':'Close'})\n",
        "new_df.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 22,
          "data": {
            "text/plain": "   Open  High   Low  Close    Volume       ewm       Date\n0  3.85  3.98  3.84   3.95  20548400  3.950000 2014-01-02\n1  3.98  4.00  3.88   4.00  22887200  3.954762 2014-01-03\n2  4.01  4.18  3.99   4.13  42398300  3.971451 2014-01-06\n3  4.19  4.25  4.11   4.18  42932100  3.991313 2014-01-07\n4  4.23  4.26  4.14   4.18  30678700  4.009283 2014-01-08",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Volume</th>\n      <th>ewm</th>\n      <th>Date</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n      <td>2014-01-02</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n      <td>2014-01-03</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n      <td>2014-01-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n      <td>2014-01-07</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n      <td>2014-01-08</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 22,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.599Z",
          "iopub.status.busy": "2022-01-28T01:13:43.371Z",
          "iopub.execute_input": "2022-01-28T01:13:43.378Z",
          "iopub.status.idle": "2022-01-28T01:13:43.389Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# column name to upper case\n",
        "new_df.rename(str.upper, axis='columns')"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 23,
          "data": {
            "text/plain": "           OPEN   HIGH        LOW      CLOSE     VOLUME        EWM       DATE\n0      3.850000   3.98   3.840000   3.950000   20548400   3.950000 2014-01-02\n1      3.980000   4.00   3.880000   4.000000   22887200   3.954762 2014-01-03\n2      4.010000   4.18   3.990000   4.130000   42398300   3.971451 2014-01-06\n3      4.190000   4.25   4.110000   4.180000   42932100   3.991313 2014-01-07\n4      4.230000   4.26   4.140000   4.180000   30678700   4.009283 2014-01-08\n...         ...    ...        ...        ...        ...        ...        ...\n1166  19.790001  20.08  19.350000  19.980000   62983200  18.890512 2018-08-20\n1167  19.980000  20.42  19.860001  20.400000   55629000  19.034273 2018-08-21\n1168  20.280001  20.92  20.209999  20.900000   62002700  19.211961 2018-08-22\n1169  21.190001  22.32  21.139999  22.290001  113444100  19.505108 2018-08-23\n1170  22.910000  24.00  22.670000  23.980000  164328200  19.931288 2018-08-24\n\n[1171 rows x 7 columns]",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>OPEN</th>\n      <th>HIGH</th>\n      <th>LOW</th>\n      <th>CLOSE</th>\n      <th>VOLUME</th>\n      <th>EWM</th>\n      <th>DATE</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>3.850000</td>\n      <td>3.98</td>\n      <td>3.840000</td>\n      <td>3.950000</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n      <td>2014-01-02</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>3.980000</td>\n      <td>4.00</td>\n      <td>3.880000</td>\n      <td>4.000000</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n      <td>2014-01-03</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.010000</td>\n      <td>4.18</td>\n      <td>3.990000</td>\n      <td>4.130000</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n      <td>2014-01-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.190000</td>\n      <td>4.25</td>\n      <td>4.110000</td>\n      <td>4.180000</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n      <td>2014-01-07</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>4.230000</td>\n      <td>4.26</td>\n      <td>4.140000</td>\n      <td>4.180000</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n      <td>2014-01-08</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>1166</th>\n      <td>19.790001</td>\n      <td>20.08</td>\n      <td>19.350000</td>\n      <td>19.980000</td>\n      <td>62983200</td>\n      <td>18.890512</td>\n      <td>2018-08-20</td>\n    </tr>\n    <tr>\n      <th>1167</th>\n      <td>19.980000</td>\n      <td>20.42</td>\n      <td>19.860001</td>\n      <td>20.400000</td>\n      <td>55629000</td>\n      <td>19.034273</td>\n      <td>2018-08-21</td>\n    </tr>\n    <tr>\n      <th>1168</th>\n      <td>20.280001</td>\n      <td>20.92</td>\n      <td>20.209999</td>\n      <td>20.900000</td>\n      <td>62002700</td>\n      <td>19.211961</td>\n      <td>2018-08-22</td>\n    </tr>\n    <tr>\n      <th>1169</th>\n      <td>21.190001</td>\n      <td>22.32</td>\n      <td>21.139999</td>\n      <td>22.290001</td>\n      <td>113444100</td>\n      <td>19.505108</td>\n      <td>2018-08-23</td>\n    </tr>\n    <tr>\n      <th>1170</th>\n      <td>22.910000</td>\n      <td>24.00</td>\n      <td>22.670000</td>\n      <td>23.980000</td>\n      <td>164328200</td>\n      <td>19.931288</td>\n      <td>2018-08-24</td>\n    </tr>\n  </tbody>\n</table>\n<p>1171 rows × 7 columns</p>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 23,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.607Z",
          "iopub.status.busy": "2022-01-28T01:13:43.399Z",
          "iopub.execute_input": "2022-01-28T01:13:43.406Z",
          "iopub.status.idle": "2022-01-28T01:13:43.418Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# column name to lower case\n",
        "new_df.rename(str.lower, axis='columns')"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 24,
          "data": {
            "text/plain": "           open   high        low      close     volume        ewm       date\n0      3.850000   3.98   3.840000   3.950000   20548400   3.950000 2014-01-02\n1      3.980000   4.00   3.880000   4.000000   22887200   3.954762 2014-01-03\n2      4.010000   4.18   3.990000   4.130000   42398300   3.971451 2014-01-06\n3      4.190000   4.25   4.110000   4.180000   42932100   3.991313 2014-01-07\n4      4.230000   4.26   4.140000   4.180000   30678700   4.009283 2014-01-08\n...         ...    ...        ...        ...        ...        ...        ...\n1166  19.790001  20.08  19.350000  19.980000   62983200  18.890512 2018-08-20\n1167  19.980000  20.42  19.860001  20.400000   55629000  19.034273 2018-08-21\n1168  20.280001  20.92  20.209999  20.900000   62002700  19.211961 2018-08-22\n1169  21.190001  22.32  21.139999  22.290001  113444100  19.505108 2018-08-23\n1170  22.910000  24.00  22.670000  23.980000  164328200  19.931288 2018-08-24\n\n[1171 rows x 7 columns]",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>open</th>\n      <th>high</th>\n      <th>low</th>\n      <th>close</th>\n      <th>volume</th>\n      <th>ewm</th>\n      <th>date</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>3.850000</td>\n      <td>3.98</td>\n      <td>3.840000</td>\n      <td>3.950000</td>\n      <td>20548400</td>\n      <td>3.950000</td>\n      <td>2014-01-02</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>3.980000</td>\n      <td>4.00</td>\n      <td>3.880000</td>\n      <td>4.000000</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n      <td>2014-01-03</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.010000</td>\n      <td>4.18</td>\n      <td>3.990000</td>\n      <td>4.130000</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n      <td>2014-01-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.190000</td>\n      <td>4.25</td>\n      <td>4.110000</td>\n      <td>4.180000</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n      <td>2014-01-07</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>4.230000</td>\n      <td>4.26</td>\n      <td>4.140000</td>\n      <td>4.180000</td>\n      <td>30678700</td>\n      <td>4.009283</td>\n      <td>2014-01-08</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>1166</th>\n      <td>19.790001</td>\n      <td>20.08</td>\n      <td>19.350000</td>\n      <td>19.980000</td>\n      <td>62983200</td>\n      <td>18.890512</td>\n      <td>2018-08-20</td>\n    </tr>\n    <tr>\n      <th>1167</th>\n      <td>19.980000</td>\n      <td>20.42</td>\n      <td>19.860001</td>\n      <td>20.400000</td>\n      <td>55629000</td>\n      <td>19.034273</td>\n      <td>2018-08-21</td>\n    </tr>\n    <tr>\n      <th>1168</th>\n      <td>20.280001</td>\n      <td>20.92</td>\n      <td>20.209999</td>\n      <td>20.900000</td>\n      <td>62002700</td>\n      <td>19.211961</td>\n      <td>2018-08-22</td>\n    </tr>\n    <tr>\n      <th>1169</th>\n      <td>21.190001</td>\n      <td>22.32</td>\n      <td>21.139999</td>\n      <td>22.290001</td>\n      <td>113444100</td>\n      <td>19.505108</td>\n      <td>2018-08-23</td>\n    </tr>\n    <tr>\n      <th>1170</th>\n      <td>22.910000</td>\n      <td>24.00</td>\n      <td>22.670000</td>\n      <td>23.980000</td>\n      <td>164328200</td>\n      <td>19.931288</td>\n      <td>2018-08-24</td>\n    </tr>\n  </tbody>\n</table>\n<p>1171 rows × 7 columns</p>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 24,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.617Z",
          "iopub.status.busy": "2022-01-28T01:13:43.429Z",
          "iopub.execute_input": "2022-01-28T01:13:43.436Z",
          "iopub.status.idle": "2022-01-28T01:13:43.448Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Selecting Multiple Columns\n",
        "new_df[new_df.columns[1:5]]"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 25,
          "data": {
            "text/plain": "       High        Low      Close     Volume\n0      3.98   3.840000   3.950000   20548400\n1      4.00   3.880000   4.000000   22887200\n2      4.18   3.990000   4.130000   42398300\n3      4.25   4.110000   4.180000   42932100\n4      4.26   4.140000   4.180000   30678700\n...     ...        ...        ...        ...\n1166  20.08  19.350000  19.980000   62983200\n1167  20.42  19.860001  20.400000   55629000\n1168  20.92  20.209999  20.900000   62002700\n1169  22.32  21.139999  22.290001  113444100\n1170  24.00  22.670000  23.980000  164328200\n\n[1171 rows x 4 columns]",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Volume</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>3.98</td>\n      <td>3.840000</td>\n      <td>3.950000</td>\n      <td>20548400</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>4.00</td>\n      <td>3.880000</td>\n      <td>4.000000</td>\n      <td>22887200</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.18</td>\n      <td>3.990000</td>\n      <td>4.130000</td>\n      <td>42398300</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.25</td>\n      <td>4.110000</td>\n      <td>4.180000</td>\n      <td>42932100</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>4.26</td>\n      <td>4.140000</td>\n      <td>4.180000</td>\n      <td>30678700</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>1166</th>\n      <td>20.08</td>\n      <td>19.350000</td>\n      <td>19.980000</td>\n      <td>62983200</td>\n    </tr>\n    <tr>\n      <th>1167</th>\n      <td>20.42</td>\n      <td>19.860001</td>\n      <td>20.400000</td>\n      <td>55629000</td>\n    </tr>\n    <tr>\n      <th>1168</th>\n      <td>20.92</td>\n      <td>20.209999</td>\n      <td>20.900000</td>\n      <td>62002700</td>\n    </tr>\n    <tr>\n      <th>1169</th>\n      <td>22.32</td>\n      <td>21.139999</td>\n      <td>22.290001</td>\n      <td>113444100</td>\n    </tr>\n    <tr>\n      <th>1170</th>\n      <td>24.00</td>\n      <td>22.670000</td>\n      <td>23.980000</td>\n      <td>164328200</td>\n    </tr>\n  </tbody>\n</table>\n<p>1171 rows × 4 columns</p>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 25,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.625Z",
          "iopub.status.busy": "2022-01-28T01:13:43.458Z",
          "iopub.execute_input": "2022-01-28T01:13:43.465Z",
          "iopub.status.idle": "2022-01-28T01:13:43.476Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Selecting rows\n",
        "new_df[1:4]"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 26,
          "data": {
            "text/plain": "   Open  High   Low  Close    Volume       ewm       Date\n1  3.98  4.00  3.88   4.00  22887200  3.954762 2014-01-03\n2  4.01  4.18  3.99   4.13  42398300  3.971451 2014-01-06\n3  4.19  4.25  4.11   4.18  42932100  3.991313 2014-01-07",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Volume</th>\n      <th>ewm</th>\n      <th>Date</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>1</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>3.954762</td>\n      <td>2014-01-03</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>3.971451</td>\n      <td>2014-01-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>3.991313</td>\n      <td>2014-01-07</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 26,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.632Z",
          "iopub.status.busy": "2022-01-28T01:13:43.486Z",
          "iopub.execute_input": "2022-01-28T01:13:43.493Z",
          "iopub.status.idle": "2022-01-28T01:13:43.506Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Create Dataframe\n",
        "stock_df = pd.DataFrame([[123.50, 145.35, 165.50], [152.35, 154.67, 160.35], [201.25, 236.54, 254.69]], columns=['IBM', 'Apple', 'Tesla'])\n",
        "stock_df"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 27,
          "data": {
            "text/plain": "      IBM   Apple   Tesla\n0  123.50  145.35  165.50\n1  152.35  154.67  160.35\n2  201.25  236.54  254.69",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>IBM</th>\n      <th>Apple</th>\n      <th>Tesla</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>123.50</td>\n      <td>145.35</td>\n      <td>165.50</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>152.35</td>\n      <td>154.67</td>\n      <td>160.35</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>201.25</td>\n      <td>236.54</td>\n      <td>254.69</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 27,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.639Z",
          "iopub.status.busy": "2022-01-28T01:13:43.517Z",
          "iopub.execute_input": "2022-01-28T01:13:43.524Z",
          "iopub.status.idle": "2022-01-28T01:13:43.536Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "stock_df = stock_df.replace([201.25, 145.35], [888, 888])\n",
        "stock_df"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 28,
          "data": {
            "text/plain": "      IBM   Apple   Tesla\n0  123.50  888.00  165.50\n1  152.35  154.67  160.35\n2  888.00  236.54  254.69",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>IBM</th>\n      <th>Apple</th>\n      <th>Tesla</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>123.50</td>\n      <td>888.00</td>\n      <td>165.50</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>152.35</td>\n      <td>154.67</td>\n      <td>160.35</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>888.00</td>\n      <td>236.54</td>\n      <td>254.69</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 28,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.646Z",
          "iopub.status.busy": "2022-01-28T01:13:43.547Z",
          "iopub.execute_input": "2022-01-28T01:13:43.554Z",
          "iopub.status.idle": "2022-01-28T01:13:43.567Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "stock_df = stock_df.replace([165.50, 160.35], ['NaN', 'NaN'])\n",
        "stock_df"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 29,
          "data": {
            "text/plain": "      IBM   Apple   Tesla\n0  123.50  888.00     NaN\n1  152.35  154.67     NaN\n2  888.00  236.54  254.69",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>IBM</th>\n      <th>Apple</th>\n      <th>Tesla</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>123.50</td>\n      <td>888.00</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>152.35</td>\n      <td>154.67</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>888.00</td>\n      <td>236.54</td>\n      <td>254.69</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 29,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.655Z",
          "iopub.status.busy": "2022-01-28T01:13:43.580Z",
          "iopub.execute_input": "2022-01-28T01:13:43.587Z",
          "iopub.status.idle": "2022-01-28T01:13:43.600Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "for index, row in stock_df.iterrows() :\n",
        "    print(row['IBM'], row['Apple'])"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "123.5 888.0\n",
            "152.35 154.67\n",
            "888.0 236.54\n"
          ]
        }
      ],
      "execution_count": 30,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "shell.execute_reply": "2022-01-28T01:13:42.664Z",
          "iopub.status.busy": "2022-01-28T01:13:43.613Z",
          "iopub.execute_input": "2022-01-28T01:13:43.619Z",
          "iopub.status.idle": "2022-01-28T01:13:43.631Z"
        }
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.6.13",
      "mimetype": "text/x-python",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "file_extension": ".py"
    },
    "kernelspec": {
      "name": "python3",
      "language": "python",
      "display_name": "Python 3"
    },
    "nteract": {
      "version": "0.28.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}